package com.example.kindergarten.controller

import com.example.kindergarten.dto.RegisterDto
import com.example.kindergarten.generator.kindergarten.KgUser
import com.example.kindergarten.generator.service.KgUserService
import com.example.kindergarten.util.ResultResponse
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@RestController("/user")
class UserContorller(
    val kguserService: KgUserService
) {

//    @Autowired(required = false)
//    lateinit var kguserService: KgUserService
//    @Autowired(required = false)
//     var kguserService = KgUserService()

    @PostMapping("/register")
    fun register(@RequestBody @Valid registerDto: RegisterDto) {
        val kgUse = KgUser()
        kgUse.username = registerDto.username
        kguserService.saveOrUpdate(kgUse)
        return
    }
}